package Logic;

import irio.gamer.gamer;
import utils.IniFile;
import utils.Vec;

public class RenderingParameters {

	/**
	 * @param args
	 */

	public Vec camera = new Vec();
	public Vec target = new Vec();
	public Vec up = new Vec();

	public Vec raystep = new Vec();
	public Vec detail_level = new Vec();
	public Vec FOV = new Vec();

	public Vec lensing = new Vec();

	public Vec lensingSize = new Vec();
	public Vec lensingStrength = new Vec();
	
	public Vec renderHealpix = new Vec();
	
	
	double randomize_spectra;
	int seed;

	public RenderingParameters(String name) {
		Load(name);
	}
	
	public void copyFrom(RenderingParameters rp) {
		camera.set(rp.camera);
		target.set(rp.target);
		up.set(rp.up);
		raystep.set(rp.raystep);
		detail_level.set(rp.detail_level);
		FOV.set(rp.FOV);
		lensing.set(rp.lensing);
		lensingSize.set(rp.lensingSize);
		lensingStrength.set(rp.lensingStrength);
		seed = rp.seed;
	}
	
	public void Load(String name) {


		try {
		IniFile ini = new IniFile(name);
		camera = ini.getVec("camera");
		target = ini.getVec("target");
		up = ini.getVec("up");
		raystep.x = ini.getDouble("raystep");
		detail_level.x = ini.getDouble("detail_level");
		randomize_spectra = ini.getDouble("randomize_spectra");
		lensing.x = ini.getDouble("lensing");
		seed = (int) ini.getDouble("seed");
		lensingStrength.x = ini.getDouble("lensing_strength");
		lensingSize.x = ini.getDouble("lensing_point_size");
		FOV.x = ini.getDouble("field_of_view");
		renderHealpix.x = ini.getDouble("render_to_healpix");
		} catch (Exception e) {
			gamer.HandleException(e, "Error loading renderparameters.ini");
		}
	}

	public void Save(String name) {
		
		gamer.gamerParams.Save();
		
		IniFile ini = new IniFile();
		ini.addKey("camera", camera);
		ini.addKey("target", target);
		ini.addKey("up", up);
		ini.addKey("raystep", raystep.x);
		ini.addKey("detail_level", detail_level.x);
		ini.addKey("randomize_spectra", randomize_spectra);
		ini.addKey("field_of_view", FOV.x);
		ini.addKey("lensing", lensing.x);
		ini.addKey("seed", seed);
		ini.addKey("lensing_point_size", lensingSize.x);
		ini.addKey("lensing_strength", lensingStrength.x);
		ini.addKey("render_to_healpix", renderHealpix.x);

		ini.Save(name);






		
	}
	
	
}
